using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Entities;
using Bll;
public partial class ChangePassword : MyPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void btnChange_Click(object sender, EventArgs e)
    {
        ArrayList arr = (ArrayList)HttpContext.Current.Session["Login"];
        AccountBll accBll = new AccountBll();
        AccountInfo acc = accBll.GetByUserName(arr[0].ToString());

        if (!txtOldPass.Text.Equals(acc.Password))
        {
            lblError.Text = "Password incorrect !";
        }
        else
        {
            lblError.Text = "";
            if (!txtNewPass.Text.Equals(txtRetypePass.Text))
            {
                lblComparePass.Text = "Re-type Passowrd Incorrect !";
            }
            else
            {
                acc.Password = txtNewPass.Text;
                acc.Username = arr[0].ToString();
                if (accBll.UpdatePassword(acc))
                {
                    Session.Remove("Login");
                    Response.Redirect("PassChanged.aspx");
                }
            }
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("MyAccount.aspx");
    }
}
